package com.shell.arouter.demo.litho;

import android.graphics.Color;

import com.facebook.litho.sections.Children;
import com.facebook.litho.sections.SectionContext;
import com.facebook.litho.sections.annotations.GroupSectionSpec;
import com.facebook.litho.sections.annotations.OnCreateChildren;
import com.facebook.litho.sections.common.SingleComponentSection;

/**
 * 说明：ListSectionSpec
 * <p/>
 * 作者：fanly
 * <p/>
 * 类型：Class
 * <p/>
 * 时间：2020-01-19 11:31
 * <p/>
 * 版本：version 1.0
 */
@GroupSectionSpec
public class ListSectionSpec {
    @OnCreateChildren
    static Children onCreateChildren(final SectionContext c) {
        Children.Builder builder = Children.create();
        for (int i = 0; i < 32; i++) {
            builder.child(
                    SingleComponentSection.create(c)
                    .key(String.valueOf(i))
                    .component(
                            ListItem.create(c)
                            .backgroundColor(i%2==0?Color.WHITE:Color.GRAY)
                            .build()
                    )
            );
        }
        return builder.build();
    }
}
